package com.fagp.mew.cms.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fagp.mew.cms.vo.AdminVo;
import com.mew.common.dc.mapper.LogMapper;
import com.mew.common.entity.back.Log;
import com.fagp.mew.cms.service.ILogService;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 后台日志 服务实现类
 * </p>
 *
 * @author ztq
 * @since 2020-11-30
 */
@Service
public class LogServiceImpl extends ServiceImpl<LogMapper, Log> implements ILogService {

    @Override
    public void insertLog(Integer operation,String thing,long userId,long number){
        AdminVo adminVo = (AdminVo) SecurityContextHolder.getContext() .getAuthentication() .getPrincipal();
        Log log = Log.builder().name(adminVo.getUsername()).operation(operation).ip(adminVo.getIp()).thing(thing).userId(userId).number(number).state(1).build();
        save(log);
    }

    public void insertLog(Integer operation,String thing,long userId){
        AdminVo adminVo = (AdminVo) SecurityContextHolder.getContext() .getAuthentication() .getPrincipal();
        Log log = Log.builder().name(adminVo.getUsername()).operation(operation).ip(adminVo.getIp()).thing(thing).userId(userId).number(0l).state(1).build();
        save(log);
    }
}
